package xcmg.device.dao.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import xcmg.device.dao.entity.barcode.BarcodeManageDO;
import xcmg.device.service.vo.barcode.BarcodeManageVO;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

@Mapper
public interface BarcodeManageMapper {
    int deleteByPrimaryKey(@Param("barcode") String barcode, @Param("orgId") String orgId);

    int insert(BarcodeManageDO record);

    int update(BarcodeManageDO record);
    
    int mergeInto(BarcodeManageDO record);

    int updateSplirIdIfNotExist(BarcodeManageDO record);

    BarcodeManageDO item(@Param("barcode") String barcode, @Param("orgId") String orgId);

    List<BarcodeManageDO> findBarcodes(@Param("barcodes") List<String> barcodes , @Param("orgId") String orgId);

    List<BarcodeManageDO> itemByBarcode(@Param("barcode") String barcode);

    List<BarcodeManageDO> itemByBarcode2(@Param("barcode") String barcode);

    List<BarcodeManageDO> list(BarcodeManageVO recode);

    List<BarcodeManageDO> findAlreadyInbound(@Param("businessOrder") String businessOrder, @Param("orgId") String orgId);

    List<BarcodeManageDO> findAlreadyOutbound(@Param("businessOrder") String businessOrder, @Param("orgId") String orgId);

    List<BarcodeManageDO> findByTotalBarcode(@Param("totalBarcode") String totalBarcode, @Param("orgId") String orgId);

    List<String> findBarcodeByTotalBarcode(@Param("totalBarcode") String totalBarcode, @Param("orgId") String orgId);

    List<BarcodeManageDO> findBarcodeForInbound(@Param("totalBarcode") String totalBarcode, @Param("orgId") String orgId);

    String locationDesc(@Param("materialsNo")String materialsNo,@Param("orgId")String orgId,@Param("warehouseCode")String warehouseCode);

    int updateBarcodeQty(@Param("qty")Integer qty, @Param("totalBarcode") String totalBarcode, @Param("orgId") String orgId);

    int updateSelfBarcodeQty(@Param("qty")BigDecimal qty, @Param("barcode") String barcode, @Param("orgId") String orgId);

    int updateTotalBarcodeQty(@Param("qty")Integer qty, @Param("totalBarcode") String totalBarcode, @Param("orgId") String orgId);

    int findMaxSeq(@Param("totalBarcode") String totalBarcode, @Param("orgId") String orgId);

    int batchInsert(List<BarcodeManageDO> list);

    String findNextSeq();

    int findChildCount(@Param("totalBarcode") String totalBarcode);

    String findSupplierOrgId(@Param("barcode") String barcode,@Param("orgId")String orgId);

    List<BarcodeManageDO> selectByBusinessOrderMatOrgId(@Param("businessOrder") String businessOrder,@Param("materialsNo") String materialsNo,@Param("orgId") String orgId);
    
    int updateBarcodeLatestOutTime(@Param("latestOutTime") Date latestOutTime,@Param("orgId") String orgId,@Param("barCode") String barCode);

    int bindTotalBarcode(@Param("barcode") String barcode, @Param("billNo") String billNo);
    
    int bindBarcode(@Param("barcode") String barcode, @Param("billNo") String billNo, @Param("orgId") String orgId);
    
    Integer getCountByBillNoAndMaterialNo(@Param("businessOrder") String businessOrder, @Param("materialsNo") String materialsNo);
    
    int getIsBindCountByTotalBarcode(@Param("totalBarcode") String totalBarcode, @Param("orgId") String orgId);
    
    int bindBarcodeByTotalBarcode(@Param("totalBarcode") String totalBarcode, @Param("billNo") String billNo, @Param("orgId") String orgId);
}
